home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / arxced / makexref / makexref.rexx next >
Encoding:
OS/2 REXX Batch file  |  1996-05-10  |  1.4 KB  |  78 lines

  1. /* 
  2. ** $VER: makexref.rexx 1.2 (10.5.96) Rolf Rotvel
  3. **
  4. ** Uses rexxtricks.library
  5. */
  6.  
  7. parse arg file
  8.  
  9. template = 'FILE/A/F '
  10. options prompt template
  11.  
  12. PARSEARG:
  13. select
  14.     when file = '' then do
  15.         say 'Required argument missing'
  16.         exit
  17.     end     
  18.     when file = '?' then do
  19.         pull file
  20.         signal parsearg
  21.     end
  22.     otherwise do
  23.     if ~readfile(file, line) then do
  24.         say 'Error reading '||file
  25.         exit 10
  26.     end
  27. end
  28.  
  29. call addlib('rexxsupport.library', 0, -30, 0)
  30. call addlib('rexxtricks.library', 0, -30, 0)
  31.  
  32. if upper(word(line.1, 1)) ~= '@DATABASE' then do
  33.     say file||' is not an AmigaGuide file'
  34.     exit 10
  35. end
  36.  
  37. filename = '"'||filepart(file)||'"'
  38. xref = makesuffix(file, 'xref', 'r')
  39.  
  40. num = 1
  41. len = 0
  42. sta = 1
  43. do forever
  44.     chk = lsearch('@node*', line, sta,, 'p')
  45.     if chk = -1 then leave  /* No more nodes */
  46.     sta = chk + 1
  47.  
  48.     node = word(line.chk, 2)
  49.     if pos('"', node) > 0 then parse upper var line.chk '"' node '"'
  50.     if node = 'MAIN' then iterate
  51.     say node
  52.  
  53.     if right(node, 2) = '()' then what.num = ' 0 1'  /* It's a function */
  54.     else what.num = ' 0 0'
  55.  
  56.     if words(node) > 1 then node.num = '"'||node||'"'
  57.     else node.num = node
  58.  
  59.     len = max(len, length(node.num))
  60.     num = num + 1
  61. end
  62. node.0 = num - 1
  63.  
  64. write.1 = 'XREF:'
  65. num = 2
  66. len = len + 2
  67.  
  68. do n = 1 to node.0
  69.     write.num = left(node.n, len)||filename||what.n
  70.     num = num + 1
  71. end
  72. write.num = '#'
  73. write.0 = num
  74.  
  75. call writefile(xref, write)
  76.  
  77. exit
  78.